{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Tce3stUlHN0L"
      },
      "source": [
        "##### Copyright 2025 Google LLC."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "id": "tuOe1ymfHZPu"
      },
      "outputs": [],
      "source": [
        "# @title Licensed under the Apache License, Version 2.0 (the \"License\");\n",
        "# you may not use this file except in compliance with the License.\n",
        "# You may obtain a copy of the License at\n",
        "#\n",
        "# https://www.apache.org/licenses/LICENSE-2.0\n",
        "#\n",
        "# Unless required by applicable law or agreed to in writing, software\n",
        "# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
        "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
        "# See the License for the specific language governing permissions and\n",
        "# limitations under the License."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "bR6s6M2SUMUx"
      },
      "source": [
        "# Gemini API: Models with REST\n",
        "\n",
        "<a target=\"_blank\" href=\"https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/rest/Models_REST.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" height=30/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0M75jc-zqqdp"
      },
      "source": [
        "This notebook demonstrates how to list the models that are available for you to use in the Gemini API, and how to find details about a model in `curl`.\n",
        "\n",
        "You can run this in Google Colab, or you can copy/paste the curl commands into your terminal.\n",
        "\n",
        "To run this notebook, your API key must be stored it in a Colab Secret named `GEMINI_API_KEY`. If you are running in a different environment, you can store your key in an environment variable. See [Authentication](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Authentication.ipynb) to learn more."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "qyEYgM6SGjTc"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "from google.colab import userdata"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "HR74aKGsLW3T"
      },
      "outputs": [],
      "source": [
        "os.environ['GEMINI_API_KEY'] = userdata.get('GEMINI_API_KEY')"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "yw0-IjXtUgCq"
      },
      "source": [
        "## Model info\n",
        "\n",
        "### List models\n",
        "\n",
        "If you `GET` the models directory, it uses the `list` method to list all of the models available through the API, including both the Gemini models."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "M2aeVCrQLc-4"
      },
      "outputs": [],
      "source": [
        "%%bash\n",
        "\n",
        "curl https://generativelanguage.googleapis.com/v1beta/models?key=$GEMINI_API_KEY"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "CLUf1EqxUWCB"
      },
      "source": [
        "### Get model\n",
        "\n",
        "If you `GET` a model's URL, the API uses the `get` method to return information about that model such as version, display name, input token limit, etc."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "PYFpfBFpUKM-"
      },
      "outputs": [],
      "source": [
        "%%bash\n",
        "\n",
        "curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview?key=$GEMINI_API_KEY"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "JZetmJD6UleV"
      },
      "source": [
        "## Learning more\n",
        "\n",
        "To learn how use a model for prompting, see the [Prompting](https://github.com/google-gemini/cookbook/blob/main/quickstarts/rest/Prompting_REST.ipynb) quickstart.\n",
        "\n",
        "To learn how use a model for embedding, see the [Embedding](https://github.com/google-gemini/cookbook/blob/main/quickstarts/rest/Embeddings_REST.ipynb) quickstart.\n",
        "\n",
        "For more information on models, visit the [Gemini models](https://ai.google.dev/models/gemini) documentation."
      ]
    }
  ],
  "metadata": {
    "colab": {
      "name": "Models_REST.ipynb",
      "toc_visible": true
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
